import React from 'react'
import {
  HashRouter as Router,
  Route,
  Redirect,
  Switch
}from 'react-router-dom'
import Login from '../views/Login'
import Dashboard from '../views/Dashboard'

const MyRouter = () =>(
  <Router>
    <Switch>
      <Route path="/login" component = { Login }/>
      <Route path="/" render = {()=>
        localStorage.getItem("isLogin") === "true"?
        <Dashboard/>
          :
        <Redirect to="/login"/>
      }/>
    </Switch>
  </Router>
)

export default MyRouter
